let arr = ['item1', 'item2', 'item3', 'item4', 'item5'];
let brr = [
    { content: "section1", index: 0 },
    { content: "section2", index: 2 }
]
injectSections = (arr, brr) => {
    let crr = []
    for (let i = 0; i < arr.length; i++) {
        for (let j = 0; j < brr.length; j++) {
            if (i == brr[j].index) {
                crr.push(brr[j].content)
            }
        }
        crr.push(arr[i])
    }
    console.log(crr, 'crr')
    // [
    //     'section1', 'item1',
    //     'item2', 'section2',
    //     'item3', 'item4',
    //     'item5'
    // ]
}
injectSections(arr, brr)
let arr1 = ['item1','item2','item3','item4','item5'];

        let arr2 = [
            {
                content:'selection1',index:0
            },
            {
                content:'selection2',index:2
            }
        ];
        function fun(arr1,arr2){

            arr2.forEach((item,index) => {
                arr1[item.index] = [item.content,arr1[item.index]]
            })
            console.log(arr1.flat())
            // arr2.forEach((item,index) => {
            //     arr1.splice((item.index+index),0,item.content);
            // })
        }

        fun(arr1,arr2)